package com.link.base.base.masterslavedbrlat.controller;

import javax.annotation.Resource;

import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.link.base.base.masterslavedbrlat.model.MasterSlaveDbRlat;
import com.link.base.base.masterslavedbrlat.service.MasterSlaveDbRlatService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 主从数据库对应关系-用于维护主从数据库表与表之间的对应关系 
 *
 * @author 谢育强
 * @date 2019/12/05 19:59
 */
@Controller
@RequestMapping("/link/masterSlaveDbRlat")
public class MasterSlaveDbRlatController extends BasicController<MasterSlaveDbRlat> {

    @Resource
    private MasterSlaveDbRlatService masterSlaveDbRlatService;

    @Override
    public BasicService<MasterSlaveDbRlat> getBasicService() throws Exception {
        return masterSlaveDbRlatService;
    }

    /**
     * 刷新canal客户端的主从数据库关系缓存，重新获取请求数据覆盖缓存
     *
     * @author 谢育强
     * @date 2019/12/17 19:33
     */
    @RequestMapping(value = "/refreshDbShipCache", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> refreshDbShipCache() {
        Map<String, Object> result = new HashMap<>();
        try {
            masterSlaveDbRlatService.refreshDbShipCache();
            result.put("success", true);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("message", e.getMessage());
        }
        return result;
    }

}
